using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using NiSis.Data;
using NiSis.Entities;


namespace NiSis
{
    /// <summary>
    /// Pagina che visualizza le utenze con pool non definito in anagrafica per il mese selezionato (cd_pool non esistente     /// nella tabella Pool)
    /// </summary>
    public partial class UtenzeNoPoolDefined : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                MeseFornitura = Request["CdMese"] ?? string.Empty;
                GrdNoPoolsRefresh();

            }
        }
        public string MeseFornitura
        {
            get
            {
                return hdMeseFornitura.Value;
            }
            set
            {
                hdMeseFornitura.Value = value;
            }
        }
        protected void GrdNoPoolsRefresh()
        {
            VList<VUtenzeNotInPool> usrList = DataRepository.VUtenzeNotInPoolProvider.Get(string.Format("cd_mese_Inizio_Fornitura='{0}'", MeseFornitura),
                "ds_cliente");

            grdUsrNoPools.Visible = usrList.Count > 0;
            grdUsrNoPools.DataSource = usrList;
            grdUsrNoPools.DataBind();
            lblTitle.Text = string.Format("{0}: {1}", lblTitle.Text, CustomUtil.DataInverter(MeseFornitura));

        }
        protected void grdUsrNoPools_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {

            //VList<VTradersPrec> results = DataRepository.VTradersPrecProvider.GetPaged(string.Format("cd_mese_Inizio_Fornitura='{0}'", "200808"), "cd_mese_Inizio_Fornitura", e.NewPageIndex, 20, out pCount);
            VList<VUtenzeNotInPool> usrList = DataRepository.VUtenzeNotInPoolProvider.Get(string.Format("cd_mese_Inizio_Fornitura='{0}'", MeseFornitura), "ds_cliente");
            grdUsrNoPools.DataSource = usrList;
            grdUsrNoPools.PageIndex = e.NewPageIndex;
            grdUsrNoPools.DataBind();

        }
        protected void grdUsrNoPools_DataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
                e.Row.Cells[3].Text = CustomUtil.DataInverter(e.Row.Cells[3].Text);
        }
    }
}
